<template>
	<view>
		<view  style="background: linear-gradient( 180deg, #FFEEEB 0%, #F8F8FA 100%);height: 310rpx;">
			<u-navbar title="88优惠" placeholder bg-color="transparent" :auto-back="true">
			
		
			</u-navbar>
		
		</view>
		<view class=" u-flex-y-center u-flex-between" style="margin-top: -140rpx;padding-top: 26rpx;padding-left:40rpx">
			
			<view>
				<view class="u-flex" style=" align-items: baseline;" @click="$u.route('/pages/member/score')">
					<view style="color: #FF8181;font-size: 88rpx;font-weight: bold;">{{user.score||0}}</view>
					<view class="u-f-32 u-bold u-m-l-10">积分</view>
				</view>
				<view class="u-f-24 u-flex-y-center" style="color: #646464;margin-top: 15rpx;">
					<text>累计消费积分</text>
					<image src="../../static/wen.png" style="width: 32rpx;height: 32rpx;margin-left: 10rpx;"  @click="$u.route('/pages/member/page?type=integral_rule')"></image>
				</view>
				<view class="u-m-t-30"  @click="$u.route('/pages/member/recharge')">
					<image src="/static/down_btn.png" style="width: 174rpx;height: 66rpx;"></image>
					<view class="u-c-fff u-f-26 u-p-r" style=" top: -52rpx;left: 46rpx;">去充值</view>
				
				</view>
			</view>
			<image src="/static/discount_bi.png" style="width: 440rpx;height: 297rpx;"></image>
		</view>
		
		<view class="u-p-30" >
			<view class="u-f-32 u-bold">活动通知</view>
			<u-gap height="40rpx"></u-gap>
			

			<swiper    :autoplay="false" style="height: 170rpx;">
				<swiper-item  v-for="(item,index) in resumeList" >
					<view class="u-bg-fff u-p-20 u-flex u-r-20" style="margin-right: 20rpx;width: 690rpx;display: inline-flex;height: 170rpx;"  @click="$u.route('/pages/message/advertInfo?id='+item.id)">
											<image :src="item.image" style="width: 206rpx;height: 130rpx;"></image>
											<view style="margin-left: 20rpx;">
												<view class="u-f-30 u-bold">{{item.name}}</view>
												<view class="u-m-t-6 u-f-24">活动时间：{{$u.timeFormat(item.update_time, 'yyyy-mm-dd hh:MM:ss')}}</view>
												<view class="u-f-24 u-f-14 u-m-t-14" style="color: #999999;">查看详情 ></view>
											</view>
										</view>
				</swiper-item>
				
			</swiper>
			<u-gap height="30rpx"></u-gap>
			<view class="u-flex u-flex-between">
				<view class="u-f-32 u-bold">兌換中心</view>
				<view class="u-flex-y-center" @click="$u.route('/pages/shop/score')"><view class="u-f-24 u-c-999">更多</view><image src="/static/right.png" style="width: 20rpx;height: 20rpx;"></image></view>
			</view>
			<u-gap height="20rpx"></u-gap>
			<view class="grid">
				<view @click="$u.route('/pages/shop/scoreDetail?is_score=1&id='+item.id)" class="u-bg-fff u-r-20" v-for="(item,index) in list" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.06);border: 1rpx solid #F7F7F8;padding-bottom: 20rpx;">
					<image :src="item.image" style="width: 335rpx;height: 198rpx;"></image>
					<view class="u-m-t-14" style="padding: 0 16rpx;">
						<view class="u-f-28 u-bold">{{item.name}}</view>
						<view class="u-f-22 u-m-t-10" style="color: #646464;">原价：￥{{item.old_price}}</view>
						<view class="u-flex " style="color: #EA4D44;align-items: baseline;">
							<block v-if="item.score > 0">
								<view class="u-f-28">{{item.score}}</view>
								<view class="u-f-22">积分</view>
								<view class="u-f-22">+</view>
							</block>
							
							<view class="u-f-28">{{item.price}}</view>
							<view class="u-f-22">元</view>
						</view>
					</view>
					
				</view>
			</view>
		</view>
			<u-gap height="100rpx"></u-gap>
	</view>
</template>

<script>
	
	export default {
		
		data() {
			return {
				user: {},
				resumeList:[],
				list: [],
				page: 1,
			}
		},
		onLoad() {
			this.getActivity()
			this.page = 1
			this.list = []
			this.getList()
		},
		onShow() {
			this.getUser()
		},
		onReachBottom() {
			this.getList()
		},
		methods: {
			async getList() {
				if (this.page == -1) {
					return
				}
			
				let url = 'shop/shopList'
				let res = await uni.$u.http.post(url, {
					page: this.page,
					is_score:1
					});
				let ls = getApp().mergePage(res, this.page, this.list);
				this.list = ls.list
				this.page = ls.total
			},
			async getActivity() {
				let res = await uni.$u.http.post('content/advertList');
				
				let ls = getApp().mergePage(res, this.page, []);
				this.resumeList = ls.list
				
		
			},
			async getUser() {
				let res = await uni.$u.http.post('user/index');
				this.user = res
		
			},
		}
	}
</script>

<style>
	page{
		background: #F8F8FA;
	}
	.grid {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		grid-gap: 20rpx;
	}
</style>